package com.qfxl.common.comm.mybatis;

import javax.persistence.Table;
import java.io.Serializable;

/**
 * 基础实体接口
 *
 * @Title: BaseBean
 * @Author cj
 * @Package org.util.note.mapper.base
 * @Date 2025/5/30 17:04
 * @description:
 */
public interface BaseBean<T extends Serializable> {
    default public String tableName() {
        String tableName = getTableNameByClazz(this.getClass());
        return tableName;
    }

    default public String getTableNameByClazz(Class<? extends BaseBean> po) {
        if (po.isAnnotationPresent(Table.class)) {
            return po.getAnnotation(Table.class).name();
        } else {
            String tName = po.getSimpleName();
            if ("po".equals(tName.substring(tName.length() - 3, tName.length() - 1))) {
                tName = tName.substring(0, tName.length() - 3);
            }
            return tName;
        }
    }


}
